package com.neural.runner;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;

import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;

import com.neural.descriptor.FeedDescriptor;
import com.neural.descriptor.NetDescriptor;
import com.neural.infrastructure.Net;
import com.neural.infrastructure.ResultPojo;
import com.neural.parser.NetPrettyPrinter;

public class Main {

	public static String[] tests = {"test/", "2.1.1/pre.AND.", "2.1.1/post.AND.",	// 0, 1, 2,
                                               "2.1.2/pre.AND.", "2.1.2/post.AND.",	// 3, 4,
                                               "2.1.3/pre.AND.", "2.1.3/post.AND.",	// 5, 6,
                                               "2.1.3/post2.AND.",					// 7
                                               "2.2.2/pre.XOR.", "2.2.2/post.XOR."	// 8, 9,
                                               };
	
	public static void main(String[] args) throws IOException {
		
		String test = tests[5];
		
		Yaml yaml = new Yaml(new Constructor(NetDescriptor.class));
		NetDescriptor netDescriptor  = (NetDescriptor) yaml.load(new FileInputStream("resources/" + test + "net.yaml"));
		Net net = new Net(netDescriptor);

		NetPrettyPrinter.printNet(net);
		NetPrettyPrinter.printWeights(net);
		NetPrettyPrinter.printValues(net);
		
		
		yaml = new Yaml(new Constructor(FeedDescriptor.class));
		FeedDescriptor feedDescriptor  = (FeedDescriptor) yaml.load(new FileInputStream("resources/"+test+"feed.yaml"));

		List<ResultPojo> resultPojos = net.feedNet(feedDescriptor);
		NetPrettyPrinter.printResults(resultPojos);
		
		NetPrettyPrinter.printWeights(net);
		NetPrettyPrinter.printValues(net);

	}
}
